﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data.SqlClient;
using System.Data;
using Microsoft.Practices.ServiceLocation;

namespace SGS.VisualLinq.UI
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
           // CreateShell();
            //Bootstrapper bootstrapper = new Bootstrapper();
            //bootstrapper.Run();
        }

        ///// <summary>
        ///// Create main window for PRISM framework
        ///// </summary>
        ///// <returns></returns>
        //protected override DependencyObject CreateShell()
        //{
        //    return ServiceLocator.Current.GetInstance<MainWindow>();
        //}

        public void ReadSchema()
        {
            SqlConnection conn = new SqlConnection(@"Data Source=CFA2-PC\SQLEXPRESS;Initial Catalog=test_db;Integrated Security=True");
            conn.Open();
            try
            {
              //  dataGrid1.DataContext =  conn.GetSchema("Tables").Columns.Cast<DataColumn>();

                foreach (var item in conn.GetSchema("Tables").Columns)
                {
                    
                }
            }
            catch (Exception ex)
            {
            }
            conn.Close();
            
        }
         
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.CSharp.CSharpCodeProvider cdProv = new Microsoft.CSharp.CSharpCodeProvider();
            System.CodeDom.Compiler.CompilerParameters cparam = new System.CodeDom.Compiler.CompilerParameters();
            cparam.GenerateInMemory=true;
            List<string> sourceCode = new List<string>();
            sourceCode.Add("from u in tblUser select u");
            var cres =  cdProv.CompileAssemblyFromSource(cparam, sourceCode.ToArray());
        }
    }
}
